//============================================================================
// Name        : layout.cpp
// Author      : dfoelber
//============================================================================

// INCLUDES //
#include "settings/layout.h"
#include "draw/SDL_draw.h"
#include "image_manager.h"
#include <iostream>
//////////////

/**
* Constructor
**/
Layout::Layout()
{
	// later, we can load these values optionally from a file, until then...
	puzzleBgX = DEFAULT_PUZZLE_BG_X;
	puzzleBgY = DEFAULT_PUZZLE_BG_Y;
	puzzleArea.x = DEFAULT_PUZZLE_REGION_X;
	puzzleArea.y = DEFAULT_PUZZLE_REGION_Y;
	puzzleArea.w = DEFAULT_PUZZLE_REGION_WIDTH;
	puzzleArea.h = DEFAULT_PUZZLE_REGION_HEIGHT;
	playerBgX = DEFAULT_PLAYER_BG_X;
	playerBgY = DEFAULT_PLAYER_BG_Y;
	playerArea.x = DEFAULT_PLAYER_REGION_X;
	playerArea.y = DEFAULT_PLAYER_REGION_Y;
	playerArea.w = DEFAULT_PLAYER_REGION_WIDTH;
	playerArea.h = DEFAULT_PLAYER_REGION_HEIGHT;
	handBgX = DEFAULT_HAND_BG_X;
	handBgY = DEFAULT_HAND_BG_Y;
	handArea.x = DEFAULT_HAND_REGION_X;
	handArea.y = DEFAULT_HAND_REGION_Y;
	handArea.w = DEFAULT_HAND_REGION_WIDTH;
	handArea.h = DEFAULT_HAND_REGION_HEIGHT;
	queueBgX = DEFAULT_QUEUE_BG_X;
	queueBgY = DEFAULT_QUEUE_BG_Y;
	queueArea.x = DEFAULT_QUEUE_REGION_X;
	queueArea.y = DEFAULT_QUEUE_REGION_Y;
	queueArea.w = DEFAULT_QUEUE_REGION_WIDTH;
	queueArea.h = DEFAULT_QUEUE_REGION_HEIGHT;
	alignmentBgX = DEFAULT_ALIGNMENT_BG_X;
	alignmentBgY = DEFAULT_ALIGNMENT_BG_Y;
	alignmentArea.x = DEFAULT_ALIGNMENT_REGION_X;
	alignmentArea.y = DEFAULT_ALIGNMENT_REGION_Y;
	alignmentArea.w = DEFAULT_ALIGNMENT_REGION_WIDTH;
	alignmentArea.h = DEFAULT_ALIGNMENT_REGION_HEIGHT;
	battleBgX = DEFAULT_BATTLE_BG_X;
	battleBgY = DEFAULT_BATTLE_BG_Y;
	battleArea.x = DEFAULT_BATTLE_REGION_X;
	battleArea.y = DEFAULT_BATTLE_REGION_Y;
	battleArea.w = DEFAULT_BATTLE_REGION_WIDTH;
	battleArea.h = DEFAULT_BATTLE_REGION_HEIGHT;
}

/**
* Deconstructor
**/
Layout::~Layout()
{
}

/**
* Creates the background with the current layout preferences.
* Caller is responsible for releasing the created surface.
*  
* @return The background
**/
Surface* Layout::CreateBackground()
{
	Surface* surface = ImageManager::GetManager()->CreateImage(1024,768);
	
	// Fill the background with black
	Draw_FillRect( surface->GetSurface(), 0, 0, 1024, 768, 0 );
	
	ImageManager::GetManager()->GetImage(IMAGE_BATTLE_REGION_BACKGROUND)->Apply(surface, 
			DEFAULT_BATTLE_BG_X, DEFAULT_BATTLE_BG_Y);
	
	ImageManager::GetManager()->GetImage(IMAGE_PUZZLE_BACKGROUND)->Apply(surface, 
			DEFAULT_PUZZLE_BG_X, DEFAULT_PUZZLE_BG_Y);
	
	ImageManager::GetManager()->GetImage(IMAGE_PLAYER_BACKGROUND)->Apply(surface, 
			DEFAULT_PLAYER_BG_X, DEFAULT_PLAYER_BG_Y);
	
	ImageManager::GetManager()->GetImage(IMAGE_HAND_REGION_BACKGROUND)->Apply(surface, 
			DEFAULT_HAND_BG_X, DEFAULT_HAND_BG_Y);
	
	ImageManager::GetManager()->GetImage(IMAGE_QUEUE_REGION_BACKGROUND)->Apply(surface, 
			DEFAULT_QUEUE_BG_X, DEFAULT_QUEUE_BG_Y);
	
	ImageManager::GetManager()->GetImage(IMAGE_ALIGNMENT_REGION_BACKGROUND)->Apply(surface, 
			DEFAULT_ALIGNMENT_BG_X, DEFAULT_ALIGNMENT_BG_Y);
	
	return surface;
}

/**
* Return's the current puzzle region's area.
* 
* @return Puzzle region's area
**/
SDL_Rect Layout::GetPuzzleRegionArea()
{
	return puzzleArea;
}

/**
* Return's the current player region's area.
* 
* @return Player region's area
**/
SDL_Rect Layout::GetPlayerRegionArea()
{
	return playerArea;
}

/**
* Return's the current hand region's area.
* 
* @return Hand region's area
**/
SDL_Rect Layout::GetHandRegionArea()
{
	return handArea;
}

/**
* Return's the current queue region's area.
* 
* @return Queue region's area
**/
SDL_Rect Layout::GetQueueRegionArea()
{
	return queueArea;
}

/**
* Return's the current alignment region's area.
* 
* @return Alignment region's area
**/
SDL_Rect Layout::GetAlignmentRegionArea()
{
	return alignmentArea;
}

/**
* Return's the current battle region's area.
* 
* @return Battle region's area
**/
SDL_Rect Layout::GetBattleRegionArea()
{
	return battleArea;
}
